#include <iostream>
#include <vector>

using namespace std;

class Solution01 {
public:
    int peakIndexInMountainArray(vector<int>& arr) {
        int left = 1, right = arr.size() - 2;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (arr[mid - 1] <= arr[mid] && arr[mid] <= arr[mid + 1])
                left = mid + 1;
            else if (arr[mid - 1] >= arr[mid] && arr[mid] >= arr[mid + 1])
                right = mid - 1;
            else 
                return mid;
        }
        return left;
    }
};

class Solution02 {
public:
    int findPeakElement(vector<int>& nums) {
        if (nums.size() == 1 || nums[0] > nums[1]) return 0;
        if (nums[nums.size() - 1] > nums[nums.size() - 2]) return nums.size() - 1;
        int left = 0, right = nums.size() - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] < nums[mid + 1])
                left = mid + 1;
            else 
                right = mid;
        }
        return left;
    }
};

class Solution03 {
public:
    // int findMin(vector<int>& nums) {
    //     int rightnum = nums.back();
    //     int left = 0, right = nums.size() - 1;
    //     while (left < right) {
    //         int mid = left + (right - left) / 2;
    //         if (nums[mid] > rightnum)
    //             left = mid + 1;
    //         else
    //             right = mid;
    //     }
    //     return nums[right];
    // }
    int findMin(vector<int>& nums) {
        if (nums.size() == 1) return nums.front();
        int leftnum = nums.front();
        int left = 0, right = nums.size() - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] >= leftnum)
                left = mid + 1;
            else
                right = mid;
        }
        if (right == nums.size() - 1 && nums[right] > nums[right - 1])
            return leftnum;
        return nums[right];
    }
};

class Solution04 {
public:
    int takeAttendance(vector<int>& records) {
        
        int left = 0, right = records.size();
        while (left < right) {
            int mid = left + (right - left) /  2;
            if (mid == records[mid])
                left = mid + 1;
            else
                right = mid;
        }
        return left;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<long long> dp(n + 1), v(n + 1);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        dp[i] = dp[i - 1] + v[i];
    }
    for (int i = 0; i < q; i++) {
        int left, right;
        cin >> left >> right;
        cout << dp[right] - dp[left - 1] << endl;
    }
    return 0;
}